package ${package_service_impl};
import ${package_dao}.${Table}Dao;
import ${package_pojo}.${Table}${pojoSuffix};
import ${package_service}.${Table}Service;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * @Author huanmin
 */
@Service
public class ${Table}ServiceImpl implements ${Table}Service {

    @Autowired
    private ${Table}Dao ${table}Dao;



    /**
     * ${Table}条件+分页查询
     * @param ${table}${pojoSuffix} 查询条件
     * @param page 页码
     * @param size 页大小
     * @return 分页结果
     */
    @Override
    public PageInfo<${Table}${pojoSuffix}> select${Table}Page(${Table}${pojoSuffix} ${table}${pojoSuffix}, int page, int size){
            //分页
            PageHelper.startPage(page,size);
            //执行搜索
            return new PageInfo<${Table}${pojoSuffix}>(select${Table}By${Table}(${table}${pojoSuffix}));
    }

    /**
     * ${Table}分页查询
     * @param page
     * @param size
     * @return 分页结果
     */
    @Override
    public PageInfo<${Table}${pojoSuffix}> select${Table}Page(int page, int size){
            //分页
            PageHelper.startPage(page,size);
            //分页查询
            return new PageInfo<${Table}${pojoSuffix}>(${table}Dao.select${Table}s());
    }



    /***
     * 查询${TableName}表的总条数
     * @return Integer
     */
    @Override
    public  Integer select${Table}Count(){
        return ${table}Dao.select${Table}Count();
    }

    /***
     * 查询${TableName}表的全部数据
     * @return List<${Table}>
     */
    @Override
    public List<${Table}${pojoSuffix}> select${Table}s(){
        return ${table}Dao.select${Table}s();
    }

   /***
   * 查询${TableName}表的主键id对应的值
   * @return ${Table}
   */
   @Override
   public ${Table}${pojoSuffix} select${Table}ById(Integer ${mapId["o_id"]}){
        return ${table}Dao.select${Table}ById(${mapId["o_id"]});
   }

   /***
   * 查询${TableName}表的指定条件(${Table})的值 (包含: 自定义排序 ,自定义分页)
   * @return List<${Table}>
   */
   @Override
   public List<${Table}${pojoSuffix}> select${Table}By${Table}(${Table}${pojoSuffix} ${table}${pojoSuffix}){
        return ${table}Dao.select${Table}By${Table}(${table}${pojoSuffix});
   }

   /***
   * 自定义查询${TableName}表的指定值,自定义查询(包含: 自定义列,自定义查询条件 , 自定义分组(分组后的赛选),自定义排序 ,自定义分页)
   * @return List<${Table}>
   */
   @Override
   public List<${Table}${pojoSuffix}> select${Table}ByCustom(${Table}${pojoSuffix} ${table}${pojoSuffix}){
        return ${table}Dao.select${Table}ByCustom(${table}${pojoSuffix});
   }


   /***
   * 插入一个${Table}对象的数据到数据库${TableName}表中,`包括` 属性值为null的数据  ,不包括主键因为一般主键都是自动生成的
   * @return Integer
   */
   @Override
   public Integer insert${Table}By${Table}(${Table}${pojoSuffix} ${table}${pojoSuffix}){
        return ${table}Dao.insert${Table}By${Table}(${table}${pojoSuffix});
   }

   /***
   * 插入一个${Table}对象的数据到数据库${TableName}表中,`不包括` 属性值为null的数据 和 不包括主键因为一般主键都是自动生成的
   * @return Integer
   */
   @Override
   public Integer insert${Table}By${Table}IsNotNull(${Table}${pojoSuffix} ${table}${pojoSuffix}){
        return ${table}Dao.insert${Table}By${Table}IsNotNull(${table}${pojoSuffix});
   }

  /***
   * 插入一批${Table}对象的数据到数据库${TableName}表中,包括属性值为null的数据  ,不包括主键因为一般主键都是自动生成的
   * @return Integer
   */
   @Override
   public Integer batchInsert${Table}By${Table}(List<${Table}${pojoSuffix}> ${table}${pojoSuffix}s){
        return ${table}Dao.batchInsert${Table}By${Table}(${table}${pojoSuffix}s);
   }

   /***
   * 插入一批${Table}对象的数据到数据库${TableName}表中,不包括属性值为null的数据 和 不包括主键因为一般主键都是自动生成的
   * @return Integer
   */
   @Override
   public Integer batchInsert${Table}By${Table}NotNull(List<${Table}${pojoSuffix}> ${table}${pojoSuffix}s){
        return ${table}Dao.batchInsert${Table}By${Table}NotNull(${table}${pojoSuffix}s);
   }



   /***
   * 根据主键ID修改${TableName}表中,括属性值为null的数据
   * @return Integer
   */
   @Override
   public Integer update${Table}ById(${Table}${pojoSuffix} ${table}${pojoSuffix}){
        return ${table}Dao.update${Table}ById(${table}${pojoSuffix});
   }

   /***
   * 根据主键ID修改${TableName}表中,不包括属性值为null的数据
   * @return Integer
   */
   @Override
   public Integer update${Table}ByIdNotNull(${Table}${pojoSuffix} ${table}${pojoSuffix}){
        return ${table}Dao.update${Table}ByIdNotNull(${table}${pojoSuffix});
   }


   /***
   * 根据主键ID删除${TableName}表中指定数据
   * @return Integer
   */
   @Override
   public Integer delete${Table}ById(Integer ${mapId["o_id"]}){
        return ${table}Dao.delete${Table}ById(${mapId["o_id"]});
   }


   /***
   * 批量主键ID删除${TableName}表中指定数据
   * @return Integer
   */
   @Override
   public Integer batchDelete${Table}ById(List<Integer> ${mapId["o_id"]}s){
        return ${table}Dao.batchDelete${Table}ById(${mapId["o_id"]}s);
   }

   /***
   * 清空${TableName}表的数据,主键自增也会重置
   * @return Integer
   */
   @Override
   public Integer clear${Table}All(){
        return ${table}Dao.clear${Table}All();
   }


}
